# /bsams/front/asset_provider/asset_provider_list.do
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

import sys

sys.path.append(r'..')
from web_base.base_page import BasePage
from page_object.login_page import LoginPage


class SupplierPage(BasePage):
    url = r'/bsams/front/asset_provider/asset_provider_list.do'
    # 搜素定位
    status_loc = (By.NAME, 'status')
    title_loc = (By.ID, 'title')
    select_ok_loc = (By.XPATH, '//*[@id="fmsearch"]/div[3]/input')

    def select_supplier(self, status, title):
        # 打开供应商管理页面
        self.open()
        self.ele_select(self.status_loc, status)
        self.ele_clear(self.title_loc)
        self.input_ele(self.title_loc, title)
        self.ele_click(self.select_ok_loc)
        sleep(3)


if __name__ == '__main__':
    status = '正常'
    title = ''

    chrome_location = r'E:\python_pro\Win_x64_1135105_chrome-win\chrome-win\chrome.exe'
    options = webdriver.ChromeOptions()
    options.binary_location = chrome_location

    driver = webdriver.Chrome(options=options)

    login_page = LoginPage(driver)
    login_page.login()

    su = SupplierPage(driver)
    su.select_supplier(status,title)
